package cn.yuanqiao.archive.appManager.domain;

import cn.yuanqiao.common.annotation.IdAnnotation;
import cn.yuanqiao.common.exception.ServiceException;
import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.common.core.domain.BaseEntity;
import cn.yuanqiao.common.utils.SecurityUtils;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Map;

/**
 * @author zjj
 * @date 2023/6/15
 */
public class TenantYqItem extends BaseEntity {
    private static final long serialVersionUID = 1L;

    public static final String BIGTABLENAME = "_YQITEM";

    public TenantYqItem() {
        String tenantCode = SecurityUtils.getTenantCode();
        if(StringUtils.isEmpty(tenantCode)){
            tenantCode = SecurityUtils.getLoginUser().getUser().getTenantCode();
            if (StringUtils.isEmpty(tenantCode)){
                throw new ServiceException("TenantCode is null");
            }
        }
        this.tableName = tenantCode.toUpperCase()+BIGTABLENAME;
    }

    private String tableName;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    @IdAnnotation
    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long itemId;

    private Map<String,String> colNames;

    public Long getItemId() {
        return itemId;
    }

    public void setItemId(Long itemId) {
        this.itemId = itemId;
    }

    public Map<String, String> getColNames() {
        return colNames;
    }

    public void setColNames(Map<String, String> colNames) {
        this.colNames = colNames;
    }
}
